package com.atguigu.ditu3.utils;

import com.atguigu.ditu3.MainActivity;
import com.atguigu.ditu3.activity.bean.ContactBean;
import com.atguigu.ditu3.activity.bean.address;
import com.atguigu.ditu3.activity.bean.dingwei;
import com.baidu.mapapi.model.LatLng;
import com.google.gson.Gson;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.OnResponseListener;
import com.yolanda.nohttp.Request;
import com.yolanda.nohttp.RequestMethod;
import com.yolanda.nohttp.RequestQueue;
import com.yolanda.nohttp.Response;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zx on 2017/11/1.
 */

public class zhuiguiji {
    private double longitudeji;
    private double latitudeji;
    private String phone;
    public zhuiguiji(double longitudeji, double latitudeji,String phone) {
        this.longitudeji = longitudeji;
        this.latitudeji = latitudeji;
        this.phone=phone;
    }

    public void star() {
        if (latitudeji > 0 && longitudeji > 0) {
            dingwei ne=new dingwei();
            ne.setLatitude(latitudeji+"");
            ne.setLongitude(longitudeji+"");
            ne.setPhone(phone);
            getlist_3(ne, Constant.TIANJIA_NOW_GUIJI);

        }
    }

    private void getlist_3(Object object, String url) {
        RequestQueue queue = NoHttp.newRequestQueue();
        Request<String> request = NoHttp.createStringRequest(url, RequestMethod.POST);
        Gson gson = new Gson();
        String json = gson.toJson(object);
        request.add("lrs", json);
        queue.add(88, request, new OnResponseListener<String>() {
            @Override
            public void onStart(int i) {

            }

            @Override
            public void onSucceed(int i, Response<String> response) {

                //  MyUtils.Toast(getApplication(), "轨迹jingjili" + response.get());
//                parseUserInfok(response.get());

            }

            @Override
            public void onFailed(int i, String s, Object o, Exception e, int i1, long l) {
            }

            @Override
            public void onFinish(int i) {

            }
        });
    }

//    private void parseUserInfok(String result) {
//
//        JSONArray jsonArray;
//        try {
//            jsonArray = new JSONArray(result);
//            for (int j = 0; j < jsonArray.length(); j++) {
//                address aa = new address();
//                JSONObject object = (JSONObject) jsonArray.getJSONObject(j);
//                aa.setLatitude(Double.parseDouble((object.optString("latitude"))));
//                aa.setLongitude(Double.parseDouble(object.optString("longitude")));
//                listl.add(aa);
//                resultPoints.add(new LatLng(aa.getLatitude(), aa.getLongitude()));
//            }
//
//
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//
//    }
}
